﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Sinacor.Servico.Bovespa.Corretagem.Service.ServiceImplementation.Translator.BusinessEntityToDataContract
{

    //Task  : 5617 
    // Data : 13/03/2009
    // Autor:Apsilva
    /// <summary>
    /// Classe para translator de BussinessEntity para DataContract
    /// </summary>
    public class Desconto
    {
        public DataContract.Response.DescontoResponse ToDescontoResponse(BusinessEntity.Desconto entity)
        {
            DataContract.Response.DescontoResponse to = new Sinacor.Servico.Bovespa.Corretagem.Service.DataContract.Response.DescontoResponse();
            to.PercentualAllIn = entity.PercentualAllIn;
            to.PercentualDescontoAcresimo = entity.PercentualDescontoAcresimo;
            DataContract.Response.PeriodoResponse periodo = new Sinacor.Servico.Bovespa.Corretagem.Service.DataContract.Response.PeriodoResponse();
            if (entity.Periodo != null)
            {
                periodo.DataInicial = entity.Periodo.DataInicial;
                periodo.DataFinal = entity.Periodo.DataFinal;
            }
            to.Periodo = periodo; 
            return to; 
        }

        public List<DataContract.Response.DescontoResponse> ToDescontoResponse(List<BusinessEntity.Desconto> entity)
        {
            List<DataContract.Response.DescontoResponse> to = new List<Sinacor.Servico.Bovespa.Corretagem.Service.DataContract.Response.DescontoResponse>();
            foreach (BusinessEntity.Desconto from in entity)
            {
                to.Add(ToDescontoResponse(from));
            }
            return to;
        }
    }
}
